package com.siashan.toolkit.sms.core.utils;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List;

/**
 * 短信工具类
 *
 * @author siashan
 * @since 1.2.0
 * @date 2023/5/18
 */
public final class SmsUtils {


    /**
     * 判断是否在白名单内
     *
     * @param whiteList      白名单
     * @param item           白名单条目
     *
     * @return 是否在白名单内
     */
    public static boolean isInWhiteList(List<String> whiteList, String item) {
        return null != whiteList && !whiteList.isEmpty() && whiteList.contains(item);
    }


    public static long getRemainSecondsOneDay() {
        Date currentDate = new Date();
        LocalDateTime midnight = LocalDateTime.ofInstant(currentDate.toInstant(), ZoneId.systemDefault()).plusDays(1)
                .withHour(0).withMinute(0).withSecond(0).withNano(0);
        LocalDateTime currentDateTime = LocalDateTime.ofInstant(currentDate.toInstant(), ZoneId.systemDefault());
        long between = ChronoUnit.SECONDS.between(currentDateTime, midnight);
        return between;
    }
}
